CentOS 6
Sponsored Link

Keep all histories of commands - psacct
2011/07/11
 
Keep all histories of commands by accton. Histories of commands are kept in users' own history file but they are possible to delete by users himselves. So accton is useful because it is owned by root and users can not edit it.
[1] accton is included in psacct package. Install it.
[root@dlp ~]#
yum -y install psacct
[2] Start psacct. It's OK all, all histories of commands are kept.
[root@dlp ~]#
/etc/rc.d/init.d/psacct start

Starting process accounting:
[ OK ]

[root@dlp ~]#
chkconfig psacct on
[3] Output histories of commands by a command below.
[root@dlp ~]#
lastcomm

bash
S
cent
ttyS0
0.01 secs Mon Jul 11 21:29

id
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

consoletype
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

dircolors
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

tput
cent
ttyS0
0.00 secs Mon Jul 11 21:29

tty
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

hostname
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

id
cent
ttyS0
0.00 secs Mon Jul 11 21:29

lastcomm
root
ttyS0
0.00 secs Mon Jul 11 21:29

chkconfig
root
ttyS0
0.00 secs Mon Jul 11 21:29

psacct
root
ttyS0
0.00 secs Mon Jul 11 21:28

touch
root
ttyS0
0.00 secs Mon Jul 11 21:28

accton
S
root
ttyS0
0.00 secs Mon Jul 11 21:28

[4] If you'd like to output histories for a user, execute with '--user' option.
[root@dlp ~]#
lastcomm --user cent

bash
S
cent
ttyS0
0.01 secs Mon Jul 11 21:29

id
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

consoletype
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

dircolors
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

tput
cent
ttyS0
0.00 secs Mon Jul 11 21:29

tty
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

hostname
cent
ttyS0
0.00 secs Mon Jul 11 21:29

bash
F
cent
ttyS0
0.00 secs Mon Jul 11 21:29

id
cent
ttyS0
0.00 secs Mon Jul 11 21:29

[5] If you'd like to output histories for a command, execute with '--command' option.
[root@dlp ~]#
lastcomm --command vim

vim
cent
ttyS0
0.06 secs Mon Jul 11 21:29

 
Tweet